<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>RVM : Magic</title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">	    
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <div class="pageheader">
					    <span class="pagetitle">
                            RVM : Magic
                                                    </span>
				    </div>
				    <div class="pagesubheading">
					    This page last changed on Jul 03, 2008 by <font color="#0050B2">dgrove</font>.
				    </div>

				    <p>Most Java runtimes rely upon the foreign language APIs of the underlying platform operating system to implement runtime behaviour which involves interaction with the underlying platform. Runtimes also occasionally employ small segments of machine code to provide access to platform hardware state. Note that this is expedient rather than mandatory. With a suitably smart Java bytecode compiler it would be quite possible to implement a full Java-in-Java runtime i.e. one comprising only compiled Java code (the JNode project is an attempt to implement a runtime along these lines; the Xerox, MIT, Lambda and TI Explorer Lisp machine implementations and the Xerox Smalltalk implementation were highly successful attemtps at fully compiled language runtimes).</p>

<p>This section provides information on <img class="emoticon" src="images/icons/emoticons/star_red.gif" height="16" width="16" align="absmiddle" alt="" border="0"/> magic <img class="emoticon" src="images/icons/emoticons/star_red.gif" height="16" width="16" align="absmiddle" alt="" border="0"/> which is an escape hatch that Jikes<a href="http://docs.codehaus.org/display/RVM/Trademarks" title="Trademarks">™</a> RVM provides to implement functionality that is not possible using the pure Java<a href="http://docs.codehaus.org/display/RVM/Trademarks" title="Trademarks">™</a> programming language. For example, the Jikes RVM garbage collectors and runtime system must, on occasion, access memory or perform unsafe casts. The compiler will also translate a call to Magic.threadSwitch() into a sequence of machine code that swaps out old thread registers and swaps in new ones, switching execution to the new thread's stack resumed at its saved PC</p>

<p>There are three mechanisms via which the Jikes RVM <img class="emoticon" src="images/icons/emoticons/star_red.gif" height="16" width="16" align="absmiddle" alt="" border="0"/> magic <img class="emoticon" src="images/icons/emoticons/star_red.gif" height="16" width="16" align="absmiddle" alt="" border="0"/> is implemented:</p>
<ul>
	<li><a href="Compiler Intrinsics.html" title="Compiler Intrinsics">Compiler Intrinsics</a>: Most methods are within class librarys but some functions are built in (that is, intrinsic) to the compiler. These are referred to as intrinsic functions or intrinsics.</li>
	<li>Compiler Pragmas: Some intrinsics are do not provide any behaviour but instead provide information to the compiler that modifies optimizations, calling conventions and activation frame layout. We rever to these mechanisms as compiler pragmas.</li>
	<li><a href="Unboxed Types.html" title="Unboxed Types">Unboxed Types</a>: Besides the primitive types, all Java values are boxed types. Conceptually, they are represented by a pointer to a heap object. However, an unboxed type is represented by the value itself. All methods on an unboxed type must be <a href="Compiler Intrinsics.html" title="Compiler Intrinsics">Compiler Intrinsics</a>.</li>
</ul>


<p>The mechanisms are used to implement the following functionality;</p>
<ul>
	<li><a href="Raw Memory Access.html" title="Raw Memory Access">Raw Memory Access</a>: Unfetted access to memory.</li>
	<li><a href="Uninterruptible Code.html" title="Uninterruptible Code">Uninterruptible Code</a>: Declaring code to be uninterruptible.</li>
	<li>Alternative Calling Conventions: Declaring different calling conventions and activation frame layout.</li>
</ul>


				    
                    			    </td>
		    </tr>
	    </table>
	    <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td height="12" background="http://docs.codehaus.org/images/border/border_bottom.gif"><img src="images/border/spacer.gif" width="1" height="1" border="0"/></td>
			</tr>
		    <tr>
			    <td align="center"><font color="grey">Document generated by Confluence on Jul 04, 2010 19:57</font></td>
		    </tr>
	    </table>
    </body>
</html>